﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace CodeCity.AutomationMachine.DomainModels
{
    public class SkyEnvironment : ModelBase
    {
        public static SkyEnvironment Instance { get; private set; }

        private DateTime now;
        private double temperature;
        private ReaderWriterLockSlim nowLocker = new ReaderWriterLockSlim();
        private ReaderWriterLockSlim temperatureLocker = new ReaderWriterLockSlim();
        public SkyEnvironment()
        {
            Instance = this;
        }

        public DateTime Now
        {
            get
            {
                return WithReadLock<SkyEnvironment, DateTime>(nowLocker, x => x.now);
            }
            set
            {
                WithWriteLock<SkyEnvironment>(nowLocker, x => x.now = value);
            }
        }
        public double Temperature
        {
            get
            {
                return WithReadLock<SkyEnvironment, double>(temperatureLocker, x => x.temperature);
            }
            set
            {
                WithWriteLock<SkyEnvironment>(temperatureLocker, x => x.temperature = value);
            }
        }
    }
}
